package com.xianggu.loadBalancing;

import com.xianggu.protocol.URL;

import java.util.List;

class RoundRobinLoadBalancingStrategy implements LoadBalancingStrategy {
    private int index = 0;

    @Override
    public URL select(List<URL> servers) {
        if (servers == null || servers.isEmpty()) {
            return null;
        }
        URL server = servers.get(index);
        index = (index + 1) % servers.size();
        return server;
    }
}